package org.sgx.gapi.client.client;

import java.util.Collection;

import org.sgx.gapi.client.apis.fusiontables.table.TableListResult;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;

/**
 * a GAPIResult that contains items and information about paging. For example, fusion tables table list and youtube search are GapiListResults.
 * 
 * @param <T>
 *            - the type of the items.
 * @author sg
 * 
 */
public class GapiListResult<T extends JavaScriptObject> extends GAPIResult {

	protected GapiListResult() {
	}

	/**
	 * List of all requested items
	 * 
	 * @return
	 */
	public native final JsArray<T> items() /*-{
		return this["items"];
	}-*/;

	/**
	 * List of all requested items
	 * 
	 * @return
	 */
	public native final Collection<T> itemsCol() /*-{
		return @org.sgx.jsutil.client.JsUtil::toJavaCollection(Lcom/google/gwt/core/client/JavaScriptObject;)(this["items"]);
	}-*/;

	/**
	 * List of all requested items
	 * 
	 * @param val
	 * @return this - for setter chaining
	 */
	public native final TableListResult items(JsArray<T> val) /*-{
		this["items"] = val;
		return this;
	}-*/;

	/**
	 * List of all requested items
	 * 
	 * @return
	 */
	public native final String nextPageToken() /*-{
		return this["nextPageToken"];
	}-*/;

	/**
	 * Token used to access the next page of this result. No token is displayed if there are no more pages left.
	 * 
	 * @param val
	 * @return this - for setter chaining
	 */
	public native final GapiListResult nextPageToken(String val) /*-{
		this["nextPageToken"] = val;
		return this;
	}-*/;
}
